/*************************************************************************
 *                                                                       *
 * This file is part of the DogosFrame distribution.  For full copyright *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:           sqbang                                              *
 * Email:            sqbang@ustc.edu                                     *
 *                                                                       *
 *************************************************************************/

namespace DOGOS
{

inline void
Database::getScalar(
    const std::string& key,
    bool& scalar)
{
    scalar = getBool(key);
}


inline void
Database::putScalar(
    const std::string& key,
    const bool scalar)
{
    putBool(key, scalar);
}


inline void
Database::getVector(
    const std::string& key,
    std::vector<bool>& array)
{
    array = getBoolVector(key);
}


inline void
Database::putVector(
    const std::string& key,
    const std::vector<bool>& array)
{
    putBoolVector(key, array);
}


inline void
Database::getScalar(
    const std::string& key,
    char& scalar)
{
    scalar = getChar(key);
}


inline void
Database::putScalar(
    const std::string& key,
    const char scalar)
{
    putChar(key, scalar);
}


inline void
Database::getVector(
    const std::string& key,
    std::vector<char>& array)
{
    array = getCharVector(key);
}


inline void
Database::putVector(
    const std::string& key,
    const std::vector<char>& array)
{
    putCharVector(key, array);
}


inline void
Database::getScalar(
    const std::string& key,
    Complex& scalar)
{
    scalar = getComplex(key);
}


inline void
Database::putScalar(
    const std::string& key,
    const Complex scalar)
{
    putComplex(key, scalar);
}


inline void
Database::getVector(
    const std::string& key,
    std::vector<Complex>& array)
{
    array = getComplexVector(key);
}


inline void
Database::putVector(
    const std::string& key,
    const std::vector<Complex>& array)
{
    putComplexVector(key, array);
}


inline void
Database::getScalar(
    const std::string& key,
    float& scalar)
{
    scalar = getFloat(key);
}


inline void
Database::putScalar(
    const std::string& key,
    const float scalar)
{
    putFloat(key, scalar);
}


inline void
Database::getVector(
    const std::string& key,
    std::vector<float>& array)
{
    array = getFloatVector(key);
}


inline void
Database::putVector(
    const std::string& key,
    const std::vector<float>& array)
{
    putFloatVector(key, array);
}


inline void
Database::getScalar(
    const std::string& key,
    double& scalar)
{
    scalar = getDouble(key);
}


inline void
Database::putScalar(
    const std::string& key,
    const double scalar)
{
    putDouble(key, scalar);
}


inline void
Database::getVector(
    const std::string& key,
    std::vector<double>& array)
{
    array = getDoubleVector(key);
}


inline void
Database::putVector(
    const std::string& key,
    const std::vector<double>& array)
{
    putDoubleVector(key, array);
}


inline void
Database::getScalar(
    const std::string& key,
    int& scalar)
{
    scalar = getInteger(key);
}


inline void
Database::putScalar(
    const std::string& key,
    const int scalar)
{
    putInteger(key, scalar);
}


inline void
Database::getVector(
    const std::string& key,
    std::vector<int>& array)
{
    array = getIntegerVector(key);
}


inline void
Database::putVector(
    const std::string& key,
    const std::vector<int>& array)
{
    putIntegerVector(key, array);
}


template<class TYPE>
inline void
Database::getObjectVector(
    const std::string& key,
    std::vector<TYPE>& vector)
{
    size_t size = getInteger(key + "_size");
    for (unsigned int i = 0; i < size; ++i) {
        const std::string index_str = Utilities::int_to_string (i);
        vector[i].getFromRestart(*this, key + "_" + index_str);
    }
}


template<class TYPE>
inline void
Database::putObjectVector(
    const std::string& key,
    const std::vector<TYPE>& vector)
{
    unsigned int size = static_cast<int>(vector.size());
    putInteger(key + "_size", size);
    for (unsigned int i = 0; i < size; ++i) {
        const std::string index_str = Utilities::int_to_string (i);
        vector[i].putToRestart (*this, key + "_" + index_str);
    }
}

}
